package com.sneakxy.cloudbase.platform.service;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.sneakxy.cloudbase.platform.bean.LauncherSetting;
import com.sneakxy.cloudbase.platform.bean.LauncherSettingId;
import com.sneakxy.cloudbase.platform.repository.LauncherSettingRepository;

/**
 * 
 * @author 潜行的青衣
 * @see
 */
@Service
public class LauncherSettingService extends BaseService<LauncherSetting, LauncherSettingId, LauncherSettingRepository> implements ILauncherSettingService {

	/**
	 * 按账户表数分表
	 */
	@Value("${merge.size.account}")
	private int mergeSize;
	
	/* (non-Javadoc)
	 * @see com.sneakxy.cloudbase.platform.service.ILauncherSettingService#deleteByLid(java.lang.String)
	 */
	@Override
	public long deleteByLid(String lid) {
		return this.getRepository().deleteByLid(lid);
	}

	@Override
	public long deleteByAccountId(String accountId, String tableName) {
		return this.getRepository().deleteByAccountId(accountId, tableName);
	}

	@Override
	public String getTableName(String accountId) {
		return this.getTableName(accountId, getMergeSize());
	}

	@Override
	public void delete(LauncherSettingId id) {
		this.delete(id, getTableName(id.getAccountId()));
	}

	@Override
	public <S extends LauncherSetting> S save(S entity) {
		return save(entity, getTableName(entity.getId().getAccountId()));
	}

	public int getMergeSize() {
		return mergeSize;
	}

}
